package com.activenetwork.util.grid.condition;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class EqualValueCondition implements Condition {
	private int column;
    private String value;
    
	public void setColumn(int column) {
		this.column = column;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public int getColumn() {
        return column;
    }
    public String getValue() {
        return value;
    }
    /**
     * Empty constructor
     */
    public EqualValueCondition(){
    	this.column = -1;
    	this.value = null;
    }
    /**
     * Direct constructor
     * @param column
     * @param value
     */
    public EqualValueCondition(int column, String value) {
        this.column = column;
        this.value = value;
    }
    
    @Override
    public boolean matchs(WebElement row) {
        boolean flag = false;
        if (value.equals(row.findElement(By.xpath("./td[" + column + "]/input")).getAttribute("value"))) {
            flag = true;
        }
        return flag;
    }
}
